﻿using System;
using System.Collections;
using System.Collections.Generic;

using Rockfan.Framework;
using Rockfan.Framework.Audio.Midi;

namespace Rockfan.Framework.Audio
{
    public sealed class NoteTracks
    {
        #region Properties

        /// <summary>
        /// Gets a value indicating the name of this object
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// Gets a value indicating whether this set of tracks contains easy notes
        /// </summary>
        public bool HasEasy { get { return Easy.Count > 0; } }

        /// <summary>
        /// Gets a value indicating whether this set of tracks contains medium notes
        /// </summary>
        public bool HasMedium { get { return Medium.Count > 0; } }

        /// <summary>
        /// Gets a value indicating whether this set of tracks contains hard notes
        /// </summary>
        public bool HasHard { get { return Hard.Count > 0; } }

        /// <summary>
        /// Gets a value indicating whether this set of tracks contains expert notes
        /// </summary>
        public bool HasExpert { get { return Expert.Count > 0; } }

        /// <summary>
        /// Gets a value indicating whether this set of tracks contains expert plus notes
        /// </summary>
        public bool HasExpertPlus { get { return ExpertPlus.Count > 0; } }

        /// <summary>
        /// Gets a collection of NoteEvents described as easy
        /// </summary>
        public NoteTrack Easy { get; private set; }

        /// <summary>
        /// Gets a collection of NoteEvents described as medium
        /// </summary>
        public NoteTrack Medium { get; private set; }

        /// <summary>
        /// Gets a collection of NoteEvents described as hard
        /// </summary>
        public NoteTrack Hard { get; private set; }

        /// <summary>
        /// Gets a collection of NoteEvents described as expert
        /// </summary>
        public NoteTrack Expert { get; private set; }

        /// <summary>
        /// Gets a collection of NoteEvents described as expert plus
        /// </summary>
        public NoteTrack ExpertPlus { get; private set; }

        /// <summary>
        /// Gets a collection of sections defined within this object
        /// </summary>
        public List<Section> Sections { get; private set; }
        
        #endregion

        #region Constructor

        /// <summary>
        /// Constructs a new instance of this object
        /// </summary>
        /// <param name="name">a string value represnting the name of this object</param>
        public NoteTracks(string name)
        {
            this.Name = name;

            Easy = new NoteTrack("Easy");
            Medium = new NoteTrack("Medium");
            Hard = new NoteTrack("Hard");
            Expert = new NoteTrack("Expert");
            ExpertPlus = new NoteTrack("ExpertPlus");
            Sections = new List<Section>();
        }

        #endregion

        public void SortAccending()
        {
            Easy.SortAccending();
            Medium.SortAccending();
            Hard.SortAccending();
            Expert.SortAccending();
            ExpertPlus.SortAccending();

            Sections.Sort((left, right) =>
                {
                    return left.Start < right.Start ? -1 : left.Start > right.Start ? 1 : 0;
                });
        }
    }
}
